home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: system() & error detection
- Date: 26 Feb 1996 13:07:48 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4gt7f4INNt1j@keats.ugrad.cs.ubc.ca>
- References: <4gt24g$dba@ncar.ucar.edu>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4gt24g$dba@ncar.ucar.edu>,
- James Adams <jadams@sage.cgd.ucar.edu> wrote:
- >Hello,
- >
- > I am attempting to use the system() call in order to have a
- >user-specified command execute in my program.
- >
- > I am wondering how I can check whether or not the command has
- >completed successfully ? I don't want the program to continue if the
- >call I make from system() produces some sort of error. I'd like to be
- >able to do something like the following:
- >
- > result = system(command);
- > if (result == ERROR)
- > exit(0);
- >
- >Is there anyway to do this ? Should I be using something other than
- >system() ?
-
- Try one of the member of the ``exec'' family of functions. These are defined by
- the POSIX.1 standard, not ISO/ANSI C.
-
- Exec lets you get the return value. It is also more secure, since system() can
- be exploited in ways which violate system security. If you are programming on
- a UNIX system, go to comp.unix.programmer and read their FAQ's. This is likely
- to be addressed.
- --
-
-